<template>
  <div class="icons">
      <swiper :options="swiperOption">
        <!-- slides -->
        <swiper-slide v-for="(page,index) of pages" :key="index" >
           <div  
            class="icon" 
            v-for="item of page" 
            :key="item.id"
           >
                <div class="icon-img">
                    <img class="icon-img-content" :src="item.imgUrl" alt="">
                </div>
                <p class="icon-font">{{item.iconTit}}</p>
            </div>
        </swiper-slide>
    </swiper>

  </div>
</template>

<script type="text/javascript">
export default {
  name: 'HomeIcons',
  props:{
      list:Array
  },
   data() {
    return {
        swiperOption: {
            pagination:'.swiper-pagination',
            autoplay:false
        }
    }
  },
  computed: {
    pages (){
          const pages = []
          this.list.forEach((item,index) =>{
              const page = Math.floor(index/10)
              if(!pages[page]){
                  pages[page] = []
              }
              pages[page].push(item)
          })
          return pages
      }
  }
}
</script>

<style lang="stylus" scoped>
 @import '~styles/varibles.styl'
 @import '~styles/mixins.styl'

.icons >>> .swiper-container
    overflow hidden
    width 100%
    height 0
    padding-bottom 34%
.icon
    overflow hidden
    float left
    width 20%
    text-align center
    margin:.16rem 0;
    .icon-img
        width 40%
        height 0
        padding-bottom 40%
        margin 0 auto .1rem
        .icon-img-content
            width 100%
    .icon-font
        font-size .12rem
        color $darkTextColor
        ellipsis()
</style>
